/*----------------------------------------------------------------------------\
|                                业务WORD正文视图
|-----------------------------------------------------------------------------
|                   Copyright (c) 2004
|-----------------------------------------------------------------------------
|此js需要调用的文件:
|------------------------------------------------------------------------------
|调用方法:
|var test=new AppDocView();  //建立对象
\----------------------------------------------------------------------------*/

function AppDocView()
{

   this.mainFrameworkName="window.top.main.workplace";      //主框架(最顶层的frameset)的名称
   //this.wordDocFrameName="docView";      //Word控件所在的帧名称
   this.VIEW_STATE_NORMAL="0";             //视图状态(正常)
   this.VIEW_STATE_MINIMIZED="1";          //视图状态(最小化)
   this.VIEW_STATE_MAXIMIZED="2";          //视图状态(最大化)
   this.view_stateValue="";
   //eval("window.top.main."+this.wordDocFrameName+".docViewChild").docView=this;
   this.flgAutoCloseMsgbox=true;
   this.msgboxShowTimeout=3000;
}

/**
* 设置主框架(最顶层的frameset)的名称
*/
AppDocView.prototype.setMainFrameworkName=function(mainFrameworkName)
{
  this.mainFrameworkName=mainFrameworkName;
}

/**
* 取主框架(最顶层的frameset)的名称
*/
AppDocView.prototype.getMainFrameworkName=function()
{
  return this.mainFrameworkName;
}

/**
* 取得Word控件所在的帧名称
*/
AppDocView.prototype.getWordDocFrameName=function()
{
  return this.wordDocFrameName;
}

/**
* 设置Word控件所在的帧名称
*/
AppDocView.prototype.setWordDocFrameName=function(wordDocFrameName)
{
  this.wordDocFrameName=wordDocFrameName;
}

/**
* 取WORD对象
*/
AppDocView.prototype.getWordDocument=function()
{
  //var path=this.parentFormPath+"."+this.frameName+".zhengWen";
  var framepath="window.top.main."+this.wordDocFrameName+".docViewChild.zhengWen";

  return eval(framepath);
}


/**
* 取attachment.dll对象
*/
AppDocView.prototype.getAttachment=function()
{
  //var path=this.parentFormPath+"."+this.frameName+".zhengWen";
  var framepath="window.top.main."+this.wordDocFrameName+".docViewChild.Attachment";

  return eval(framepath);
}



/**
* 取附件管理对象
*/
AppDocView.prototype.getAttachmentContainer=function()
{
  var framepath="window.top.main."+this.wordDocFrameName+".docViewChild";
  return eval(framepath).attachment;
}

/**
* word状态改变
*/
AppDocView.prototype.word_OnStatusChanged=function()
{

}


AppDocView.prototype.showAttachmentCount=function()
{
   var attachmentContainer=this.getAttachmentContainer();

   var attachmentDIV="window.top.main."+this.wordDocFrameName+".docViewChild.attchmentCont";
   eval(attachmentDIV).innerHTML="<font size=2 color=red>附件个数:"+attachmentContainer.getAttachMentCount();+"</font>";
}

/**
*隐藏正文
*/
AppDocView.prototype.hideWordDocument=function()
{
  var framepath="window.top.main."+this.wordDocFrameName;
  eval(framepath).hiddenEve('wordDIV','word_sh');
}

/*
AppDocView.prototype.openWordDoc=function()
{
  var framepath="window.top.main."+this.wordDocFrameName;
  var wordApp=eval(framepath);
  wordApp.openWordDoc();
}
*/
/**
* 显示正文
*/
AppDocView.prototype.showWordDocument=function()
{
  var framepath="window.top.main."+this.wordDocFrameName;
  eval(framepath).showDIV('wordDIV','word_sh');
}

/**
* 移走附件对象
*/
AppDocView.prototype.removeAttachment=function()
{
  var framepath="window.top.main."+this.wordDocFrameName;
  eval(framepath).removeAttachment();
}

/**
* 增加附件对象
*/
AppDocView.prototype.addAttachment=function()
{
  var framepath="window.top.main."+this.wordDocFrameName;
  eval(framepath).addAttachment();
}


/**
* 隐藏附件
*/
AppDocView.prototype.hideAttachment=function()
{
  var framepath="window.top.main."+this.wordDocFrameName+".docViewChild";
  eval(framepath).hiddenEve('attachMentDiv','attachMent_sh');
}

/**
* 显示附件
*/
AppDocView.prototype.showAttachment=function()
{
  var framepath="window.top.main."+this.wordDocFrameName+".docViewChild";
  eval(framepath).showDIV('attachMentDiv','attachMent_sh');
}

/**
* 视图状态
*/
AppDocView.prototype.viewState=function(state)
{
  var framepath="window.top.main."+this.mainFrameworkName;
  var frameset=eval(framepath);

  if(state==this.VIEW_STATE_NORMAL)
  {
    //if(this.view_stateValue=="")
    //  frameset.rows ="*,200";
    //else
    // frameset.rows =this.view_stateValue;
  }

  if(state==this.VIEW_STATE_MINIMIZED)
  {
    //frameset.rows ="*,0";
  }
  if(state==this.VIEW_STATE_MAXIMIZED)
  {
    //frameset.rows ="30,*";
  }

}

/**
*
*/
AppDocView.prototype.viewSize=function(viewSize)
{
   var framepath="window.top.main."+this.mainFrameworkName;
   var frameset=eval(framepath);
   frameset.rows =viewSize;
   this.view_stateValue=viewSize;
}
/**
* 隐藏消息框
*/
AppDocView.prototype.closeMsgBox=function()
{
  var msgbox=document.getElementById("msgDiv");
  if(msgbox!=null)
  {
    msgbox.style.display="none";
  }
}
/**
* 消息对话框
*/
AppDocView.prototype.showMsgBox=function(message)
{
 if(document.getElementById("msgDiv")==null)
 {
  var msgDivStr="<DIV id=\"msgDiv\" style=\"HEIGHT: 77px; LEFT: 420px; POSITION: absolute; "+
                " TOP: 276px; WIDTH: 373px; Z-INDEX: 1\">"+
                " <TABLE bgColor=#ffffff class=\"box\" border=1 borderColorDark=#ffffff"+
                "  borderColorLight=#f0f0f0 cellPadding=0 cellSpacing=0 width=\"100%\">"+
                " <TR>"+
                " <TD height=1 align=\"center\" bgcolor=\"#CED4D6\">::系 统 提 示::</TD>"+
                " </TR>"+
                " <TR vAlign=top>"+
                " <TD height=65 align=\"center\" valign=\"middle\" bgcolor=\"#FFFFFF\">"+
                " <DIV id=\"msgbox\"></Div>&nbsp;</TD>"+
                " </TR>"+
                " </TABLE>"+
                " </DIV>";
   document.write(msgDivStr);


 }

 var msgbox=document.getElementById("msgDiv");
 if(msgbox!=null)
 {
   //用于把层放到浏览器中间
   msgbox.style.left=((document.body.offsetWidth-parseFloat (msgbox.style.width))/2)+document.body.scrollLeft;
   msgbox.style.top=((document.body.offsetHeight-parseFloat (msgbox.style.height))/2)+document.body.scrollTop;
   msgbox.style.display="block";
 }

 msgbox=document.getElementById("msgbox");
 msgbox.innerHTML=message;

 //自动关闭对话框
  if(this.flgAutoCloseMsgbox)
  {
    var thisObj=this;
    window.setTimeout(function () {thisObj.closeMsgBox();}, this.msgboxShowTimeout);
  }
}
/**
* 清除各对象中的数据
*/
AppDocView.prototype.ClearData=function()
{
  try
  {
   var errInfo="";
   var framepath="window.top.main."+this.wordDocFrameName+".docViewChild";
   var attachMent_container=eval(framepath).attachment;
   attachMent_container.clearAttachMent();
   attachMent_container.attachMentGrid();

   var wordApp=eval("window.top.main."+this.wordDocFrameName+".docViewChild.zhengWen");
   wordApp.closeDoc(errInfo);

   var viewState_img=eval("window.top.main."+this.wordDocFrameName).img_viewState;
   viewState_img.src="/img/common/viewmaximize.gif";
  }catch(e){}

}

